package ca.cbc.medialib.entity;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;

import ca.cbc.medialib.entity.enums.ProcessStatus;

import java.util.Date;


@Entity
@Table(name = "processing_status")
public class ProcessingStatus {
    private long id;    //release id
    private ProcessStatus status;    //process status
    private Date startTime;

    public ProcessingStatus() {
    }

    public ProcessingStatus(long id, ProcessStatus status) {
        this.setId(id);
        this.setStatus(status);
        startTime = new Date();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ProcessingStatus fm = (ProcessingStatus) o;
        if (this.getId() != fm.getId() || this.getStatus() != fm.getStatus())
            return false;

        return true;
    }

    @Id
    public long getId() {
        return id;
    }

    @Enumerated(EnumType.STRING)
    public ProcessStatus getStatus() {
        return status;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date t) {
        this.startTime = t;
    }


    @Override
    public int hashCode() {
        int result = 31 * (int) id;
        return result;
    }

    public void setId(long id) {
        this.id = id;
    }

    public void setStatus(ProcessStatus status) {
        this.status = status;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("ProcessStatus");
        sb.append("{releaseId=").append(id);
        sb.append(", status=").append(status);
        sb.append(", startTime=").append(startTime);
        sb.append('}');
        return sb.toString();
    }
}
